package com.example.eeuse.model;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class FareResult {

    private ResponseStruc responseStruc;
    private HeaderStruc headerStruc;
    private List<FareXx> fareXxList;
    @Data
    public static class ResponseStruc{

       private FareSrAr fareSrAr;
    }

    @Data
    public static class HeaderStruc{
        private String timeReceived;
        private String timeReplied;
        private String timeSent;
        private String transRef;
    }

    @Data
    public static class FareSrAr{
        private List<FareXx> fareXxList;
    }

    @Data
    public static class FareXx{
        private CooperatorXx cooperatorXx;
        private String departureClass;
        private String contractId;
        private String displayFlag;
        private String openFlag;
        private String cacheable;
        private String viaList;
        private String commissionList;
        private String vipFare;
        private String journeyType;
        private String departure;
        private String destination;
        private String outCarrier;
        private String fareRule;
        private String codeShare;
        private String publishedFare;
        private String tourCode;
        private String acCode;
        private String fareCode;
        private String fareBasis;
        private String fareBasisCh;
        private String fareBasisIn;
        private String journey;
        private String sectorPrice4Ad;
        private String sectorPrice4Ch;
        private String sectorPrice4In;
        private String fareReference;
        private FltsObInAr fltsObInAr;
        private String fltsObExAr;
        private String fltsIbInAr;
        private String fltsIbExAr;
        private String mileageFare;
        private String mileageFares;
        private String pointFare;
        private TicketingInfo ticketingInfo;
        private String todsObAr;
        private String todsIbAr;
        private String tempFareFlag;
        private String travelStart;
        private String travelEnd;
        private String combineRule;
        private String isCouponFare;
        private String couponFareBasis;
        private String refunds;
        private String reissues;
        private boolean dpFare;
        private boolean gfare;
        private boolean chInFare;

        public String parseId()
        {
            return this.getDepartureClass() +"_"+this.getContractId()+"_"+this.getFareBasis()+"_"+this.getFareReference();
        }
    }


    @Data
    public static class FltsObInAr{
        List<String> flightNumberFromList;
    }


    @Data
    public static class CooperatorXx{

        private List<Cooperator> cooperatorList;
    }


    @Data
    public static class Cooperator{
        private List<Copartner> copartnerList;
        private Price price;
        public String id()
        {
           return SecureUtil.md5(JSON.toJSONString(this));
        }
    }

    @Data
    public static class Copartner{
       private String owFareBasis;
        private String code;
        private String compareMode;
        private String rtFareBasis;
    }

    @Data
    public static class Price{
        private double  adult;
        private double child;
        private double infant;
    }

    @Data
    public static class TicketingInfo{
       private TicketSr ticketSr;
       private List<NvbaSr> nvbaSrList;
       private String refund;
       private String reissue;
       private RefundSr refundSr;
       private String reissueSr;
    }


    @Data
    public static class Msg{

        private String message;
        private String messageEn;
        private String messageZh;
        private String ptc;
        private List<RefundDetail> refundDetails;
    }
    @Data
    public static class RefundDetail{

        private String applyNoRefund;
        private String autoNote;
        private String autoNoteEn;
        private String autoNoteSimple;
        private String autoNoteZh;
        private String bookingClass;
        private String chargeBookingClass;
        private String charges;
        private String fareBasis;
        private String fixedCharge;
        private String fixedClass;
        private String fixedPercent;
        private String flightDateEnd;
        private String flightDateEndUnit;
        private String flightDateStart;
        private String flightDateStartUnit;
        private String flightType;
        private String journeyType;
        private String lowestCharge;
        private int percentage;
        private String psgrType;
        private String refundable;
        private String unusedCharge;
        private String unusedTax;
        private String useStatus;

    }
    @Data
    public static class RefundSr{

        private List<Msg> msgList;
    }
    @Data
    public static class TicketSr{

        private String endorsement;
        private String baggage_amount;
        private String couponNote;
    }

    @Data
    public static class NvbaSr{

       private String fareCode;
        private String depCode;
        private String arrCode;
        private String notValidBefore;
        private String notValidBeforeValue;
        private String notValidAfter;
        private String notValidAfterValue;
        private String freeBaggageAllowance;
        private String freeBaggageAllowanceUnit;
        private String adultFreeBaggageAllowance;
        private String childFreeBaggageAllowance;
        private String infantFreeBaggageAllowance;
        private String adultFreeBaggageAllowanceUnit;
        private String childFreeBaggageAllowanceUnit;
        private String infantFreeBaggageAllowanceUnit;
        private String adultCommissionAmount;
        private String childCommissionAmount;
        private String infantCommissionAmount;
        private String fixedCommissionMap;
    }
}
